/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model.humanbody


import static org.junit.Assert.*
import model.agent.AgentInterface
import model.agent.AgentVariable;

import org.junit.After
import org.junit.AfterClass
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Test

/**
 *
 * @author itsaquestion
 */

class OrganTest {
	
	final shouldFail = new GroovyTestCase().&shouldFail

	public OrganTest() {
	}

	@BeforeClass
	public static void setUpClass() {
	}

	@AfterClass
	public static void tearDownClass() {
	}

	@Before
	public void setUp() {
		
	}

	@After
	public void tearDown() {
	}


	@Test
	public void test(){
		
		//常规的操作
		def organ = new Organ("心")

		assert(organ.name == "心")
		
		def p = new AgentVariable("心气虚")
		
		organ.addVariable(p)
		
		//println organ.getPValue("心气虚")
		
		
		
		assert(organ.心气虚 == 0)

		organ.心气虚 ++ 
		
		assert(organ.心气虚 == 1)
		
		def p2 = new AgentVariable("心血虚")
		
		organ.addVariable(p2)
		
		assert(organ.toString() == "心气虚=1.0\n心血虚=0.0\n")
		
		organ.setVarValue("心气虚",1)
		
		organ.resetVars()
		assert(organ.心气虚 == 0)
		
		//println organ.getVarsMap()
		
		//不存在的属性
		shouldFail(Exception) {
			organ.setVarValue("心阴虚",1)
		}
		
		shouldFail(Exception) {
			organ.getVarValue("心阴虚",1)
		}
		
		shouldFail(Exception) {
			organ.getSubAgent("某主体")
		}
		
		shouldFail(Exception) {
			organ.addSubAgent("某主体")
		}
		
		shouldFail(Exception) {
			organ.removeSubAgent("某主体")
		}
		
	}
	
	
}
